home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 40
/
Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso
/
Aminet
/
misc
/
emu
/
ATUtilities.lha
/
ATUtilities
/
ohelp.bbq
< prev
next >
Wrap
Text File
|
2000-09-26
|
27KB
|
1,215 lines
/* ******************************************************************* */
/* ** ** */
/* ** ATUtilities Online Help ** */
/* ** Copright (C) 1992-1993 by Thomas Dreibholz ** */
/* ** All rights reserved ** */
/* ** ** */
/* ******************************************************************* */
#define PAGE_INDEX 1
#define PAGE_TEXT 2
#define ZEILEN 25
#include "ATUtilities.h"
/*
#define CreateBoolGadget(win,x,y,w,h,text,id) CreateBoolToggleGadget(0,win,x,y,w,h,text,id)
#define CreateMinGadget(win,x,y,w,h,id) CreateBoolToggleGadget(4,win,x,y,w,h,0L,id)
*/
extern struct Library *DiskfontBase;
/* feste Strukturen */
UWORD Strings=66;
UBYTE *String[]=
{
"",
"\x9b1;33;40mBedienung des Online-Hilfesystems\x9b0;33;40m",
"",
"",
"\x9b4;33;40mAuswahl von Seiten\x9b0;33;40m",
"",
"Beim Aufruf des Hilfesystems wird zuerst der Hauptindex geladen. Durch",
"Klicken auf die Gadgets im Index gelangt man zu den entsprechenden",
"Seiten.",
"",
"Am unteren Bildschirmrand befindet sich mindestens ein Gadget; maximal",
"jedoch vier. Mit ihnen kann zur nächsten bzw. vorhergehenden Seite ge-",
"wechselt werden.",
"",
"Gadget-Positionen und ihre Funktionen",
"",
"[Vorherg. Index] [Vorherg. Texts.] [Nächste Texts.] [Nächster Index]",
"",
"",
"\x9b4;33;40mSeitentypen\x9b0;33;40m",
"",
"",
"Indexseiten"
"",
"Auf Indexseiten befinden sich Gadgets, die zu den entsprechenden Text-",
"seiten führen.",
"",
"",
"Textseiten",
"",
"Auf diesen Seiten stehen die Hilfstexte. Ist der Text größer als der",
"im Textfenster zur Verfügung stehende Platz, so läßt sich der Text-",
"ausschnitt mit dem Proportional-Gadget am rechten Bildschirmrand ver-",
"schieben.",
"Besitzt die Seite Querverweise auf andere Seiten, so sind diese im",
"Menü \"Querverweise\" aufgelistet. Durch Anwahl des entsprechenden",
"Menüpunktes wird die Seite geladen.",
"Gleiches gilt für Bilder und Diagramme im Menü \"Bilder\".",
"",
"",
"\x9b4;33;40mDas Datei-Menü\x9b0;33;40m",
"",
"",
"Der Menüpunkt \"Einstellungen ändern\"",
"",
"Hier lassen sich die Grundeinstellungen des Hilfesystems ändern:",
"Cache-Modus: Die Hilfedatei wird beim Start komplett in den Haupt-",
" speicher geladen. Bei Systemen mit wenig Speicher kann",
" der Modus ausgeschaltet werden. Bei jeder neuen Seite",
" wird dann vom Datenträger nachgeladen."
"",
"",
"Der Menüpunkt \"Bedienungshinweise\"",
"",
"Hiermit wird dieser Text angezeigt.",
"",
"",
"Der Menüpunkt \"Information\"",
"",
"Hiermit werden Informationen über das Hilfesystem, die Version und",
"den noch freien Speicher im Amiga und auf einer eventuell vorhan-",
"denen PC/AT-Brückenkarte angezeigt.",
"",
"",
"Der Menüpunkt \"Hilfe beenden\"",
"",
"Hiermit wird das Hilfesystem geschlossen und in das Anwendungs-",
"programm zurückgekehrt."
};
struct TextAttr Opal=
{
"opal.font",
9,
FS_NORMAL,
FPF_DISKFONT
};
struct NewScreen HelpScreen=
{
0,0,640,256,3,
0,1,
HIRES,
CUSTOMSCREEN,
NULL,
NULL,NULL,NULL
};
struct Page
{
UWORD Length;
UWORD Flags;
ULONG Offset;
ULONG TextOffset;
ULONG GadgetOffset;
};
struct Pages
{
struct Page Page[1000];
};
#define GOFFSET(x) hd->Pages->Page[x].GadgetOffset
#define TOFFSET(x) hd->Pages->Page[x].TextOffset
#define OFFSET(x) hd->Pages->Page[x].Offset
#define LENGTH(x) hd->Pages->Page[x].Length
#define FLAGS(x) hd->Pages->Page[x].Flags
struct HelpData
{
struct Screen *Screen;
struct Window *MainWindow;
struct Window *IndexWindow;
struct Window *TextWindow;
struct MenuStrip *MenuStrip;
struct Menu *DateiMenu;
struct Menu *QVMenu;
struct Menu *BilderMenu;
struct Window *GadWindow;
struct Gadget *PropGadget;
struct PropInfo *PropInfo;
struct RastPort *MainRastPort;
struct RastPort *IndexRastPort;
struct MsgPort *MainUserPort;
struct MsgPort *IndexUserPort;
struct MsgPort *TextUserPort;
struct MsgPort *GadUserPort;
struct TextFont *OpalFont;
struct ViewPort *ViewPort;
struct MsgPort *ConPort;
struct IOStdReq *ConReq;
LONG ConDev;
struct FileHandle *HelpFile;
UBYTE *Memory;
struct Pages *Pages;
UWORD Page;
UWORD Flags;
ULONG MainWindowSM;
ULONG IndexWindowSM;
ULONG TextWindowSM;
ULONG GadWindowSM;
ULONG WaitSM;
UWORD NextPage[4];
UWORD IGy;
UWORD IGw;
UWORD IGs;
UWORD IGPCount;
struct Gadget *IndexGadgets[64];
UWORD IndexGadgetPages[64];
UWORD MenuPageCount;
UWORD MenuNames[25][70];
UWORD MenuPages[25];
UWORD PropBody;
UWORD LineCount;
UWORD CurrentLine;
UBYTE *Lines[2000];
};
UWORD Colors[]={0x97a,0x222,0xddd,0xff5,0xdd6,0xccc,0xfff,0x22f};
BOOL OpenHelp();
VOID CloseHelp();
VOID ConWrite();
VOID RefreshGadWindow();
VOID GetTitle();
VOID LoadPage();
VOID ShowIndexPage();
VOID ShowTextPage();
VOID RemIndexGadgets();
VOID NewProp();
VOID ShowPart();
VOID MakeMenu();
VOID Hinweise();
UBYTE *GetOpalLine();
UBYTE *GetOpalLine450();
VOID RemoveMenuStrip();
VOID UseMenuStrip();
struct MenuStrip *BuildMenuStrip();
struct Menu *AddMenu();
struct Menu *AddItem();
/* Informationen anzeigen */
VOID ShowInfo(win,scr)
struct Window *win;
struct Screen *scr;
{
WBenchToFront();
InformationBox("ATUtilities Online Help - Information",
"Online Help - Version 2.0",
"Copyright (C) 1993 by",
"Thomas Dreibholz",
"All rights reserved.",
"SYS:PC/ATUtilities/Icons/Help");
ScreenToFront(scr);
ActivateWindow(win);
}
/* Online-Hilfe-Funktion */
VOID Help(name,seite)
UBYTE *name;
UWORD seite;
{
struct IntuiMessage *msg;
struct HelpData *hd;
struct Gadget *gad;
ULONG Class;
BOOL ende,bool;
UWORD i,j,Code;
UWORD MenuNum,ItemNum;
ULONG Signale;
if(DiskfontBase==NULL)
{
InfoRequest("Keine Diskfont-Library!");
return;
}
hd=AllocMem(sizeof(struct HelpData),MEMF_CLEAR|MEMF_PUBLIC);
if(hd==NULL)
{
ErrorRequest(ERROR_ALLOC);
return;
}
bool=OpenHelp(hd,name);
if(bool==TRUE)
{
ende=FALSE;
while(ende==FALSE)
{
Signale=Wait(hd->WaitSM);
if((hd->GadUserPort!=NULL) && (Signale & hd->GadWindowSM))
{
msg=GetMsg(hd->GadUserPort);
if(msg!=NULL)
{
Class=msg->Class;
gad=msg->IAddress;
ReplyMsg(msg);
if(Class==GADGETUP)
{
j=gad->GadgetID;
LoadPage(hd,hd->NextPage[j]);
}
else if(Class==ACTIVEWINDOW)
ActivateWindow(hd->MainWindow);
}
}
if(Signale & hd->MainWindowSM)
{
msg=GetMsg(hd->MainUserPort);
if(msg!=NULL)
{
Class=msg->Class;
Code=msg->Code;
gad=msg->IAddress;
ReplyMsg(msg);
switch(Class)
{
case GADGETUP:
j=gad->GadgetID;
switch(j)
{
case 1:
ende=TRUE;
break;
case 2:
LoadPage(hd,0);
break;
case 3:
if(hd->Flags==PAGE_TEXT)
{
j=hd->PropInfo->VertPot/(65535/hd->PropBody);
ShowPart(hd,j);
}
break;
}
break;
case MENUPICK:
MenuNum=MENUNUM(Code);
ItemNum=ITEMNUM(Code);
switch(MenuNum)
{
case 2:
switch(ItemNum)
{
case 0:
ende=TRUE;
break;
case 2:
ShowInfo(hd->MainWindow,hd->Screen);
break;
case 3:
Hinweise(hd);
break;
}
break;
case 1:
if((hd->MenuPageCount!=0)&&(ItemNum<=hd->MenuPageCount))
LoadPage(hd,hd->MenuPages[hd->MenuPageCount-ItemNum-1]);
break;
}
break;
}
}
}
if(Signale & hd->IndexWindowSM)
{
msg=GetMsg(hd->IndexUserPort);
if(msg!=NULL)
{
Class=msg->Class;
gad=msg->IAddress;
ReplyMsg(msg);
if(Class==GADGETUP)
{
j=gad->GadgetID;
LoadPage(hd,hd->IndexGadgetPages[j]);
}
else if(Class==ACTIVEWINDOW)
ActivateWindow(hd->MainWindow);
}
}
if(Signale & hd->TextWindowSM)
{
msg=GetMsg(hd->TextUserPort);
if(msg!=NULL)
{
Class=msg->Class;
ReplyMsg(msg);
if(Class==ACTIVEWINDOW)
ActivateWindow(hd->MainWindow);
}
}
}
}
CloseHelp(hd);
FreeMem(hd,sizeof(struct HelpData));
}
BOOL OpenHelp(hd,name)
struct HelpData *hd;
UBYTE *name;
{
UBYTE c;
WORD a,i;
LONG b;
static struct NewWindow MainWindowDef=
{
0,0,640,256,
0,2,
GADGETUP|MENUPICK,
NOCAREREFRESH|ACTIVATE|BORDERLESS,
NULL,NULL,NULL,NULL,NULL,
10,16,640,256,
CUSTOMSCREEN
};
static struct NewWindow IndexWindowDef=
{
11,26,582,210,
0,1,
GADGETUP|ACTIVEWINDOW,
BORDERLESS,
NULL,NULL,NULL,NULL,NULL,
10,16,640,256,
CUSTOMSCREEN
};
static struct NewWindow TextWindowDef=
{
12,27,580,208,
0,1,
ACTIVEWINDOW,
BORDERLESS,
NULL,NULL,NULL,NULL,NULL,
10,16,640,256,
CUSTOMSCREEN
};
hd->ConDev=-1L;
hd->OpalFont=GetOpalFont();
if(hd->OpalFont==NULL)
{
InfoRequest("Opal-Font fehlt!");
return(FALSE);
}
hd->Screen=OpenScreen(&HelpScreen);
if(hd->Screen==NULL)
{
InfoRequest("Kann Screen nicht öffnen!");
return(FALSE);
}
hd->ViewPort=&hd->Screen->ViewPort;
LoadRGB4(hd->ViewPort,&Colors,8);
MainWindowDef.Screen=hd->Screen;
IndexWindowDef.Screen=hd->Screen;
TextWindowDef.Screen=hd->Screen;
hd->IndexWindow=OpenWindow(&IndexWindowDef);
if(hd->IndexWindow==NULL)
{
InfoRequest("Kann Fenster nicht öffnen!");
return(FALSE);
}
hd->TextWindow=OpenWindow(&TextWindowDef);
if(hd->TextWindow==NULL)
{
InfoRequest("Kann Fenster nicht öffnen!");
return(FALSE);
}
hd->MainWindow=OpenWindow(&MainWindowDef);
if(hd->MainWindow==NULL)
{
InfoRequest("Kann Fenster nicht öffnen!");
return(FALSE);
}
hd->MainRastPort=hd->MainWindow->RPort;
hd->IndexRastPort=hd->IndexWindow->RPort;
hd->MainUserPort=hd->MainWindow->UserPort;
hd->IndexUserPort=hd->IndexWindow->UserPort;
hd->TextUserPort=hd->TextWindow->UserPort;
hd->MainWindowSM=(1L<<hd->MainUserPort->mp_SigBit);
hd->IndexWindowSM=(1L<<hd->IndexUserPort->mp_SigBit);
hd->TextWindowSM=(1L<<hd->TextUserPort->mp_SigBit);
hd->MainWindow->UserData=NULL;
hd->IndexWindow->UserData=NULL;
hd->TextWindow->UserData=NULL;
SetFont(hd->MainRastPort,hd->OpalFont);
SetFont(hd->IndexRastPort,hd->OpalFont);
CreateBoolGadget(hd->MainWindow,10,10,150,12,"Ende",1);
CreateBoolGadget(hd->MainWindow,165,10,150,12,"Index",2);
hd->PropGadget=CreatePropGadget(hd->MainWindow,600,25,30,211,0,0,0,(65535/10),3);
hd->PropInfo=hd->PropGadget->SpecialInfo;
DrawNBorder(hd->MainWindow,10,25,584,211);
SetAPen(hd->MainRastPort,3);
WriteText(hd->MainRastPort,40,40,"ATUtilities Online-Hilfe - Version 2.0");
WriteText(hd->MainRastPort,40,60,"Hilfedatei wird bearbeitet.");
WriteText(hd->MainRastPort,40,80,"Bitte warten...");
hd->ConPort=CreatePort("onlinehelp-console.port",0L);
if(hd->ConPort==NULL)
{
InfoRequest("Kann MsgPort nicht erstellen!");
return(FALSE);
}
hd->ConReq=CreateExtIO(hd->ConPort,sizeof(struct IOStdReq));
if(hd->ConReq==NULL)
{
InfoRequest("Kann IOStdReq nicht erstellen!");
return(FALSE);
}
hd->ConReq->io_Data=hd->TextWindow;
hd->ConReq->io_Length=sizeof(struct Window);
hd->ConDev=OpenDevice("console.device",0L,hd->ConReq,0L);
if(hd->ConDev!=0)
{
InfoRequest("Kann Console-Device nicht öffnen!");
return(FALSE);
}
ConWrite(hd,"\x9b");
ConWrite(hd,"0;33;40m");
hd->HelpFile=Open(name,MODE_OLDFILE);
if(hd->HelpFile==NULL)
{
MultiRequest("Kann Hilfedatei nicht öffnen:",name,"Okay",NULL);
return(FALSE);
}
hd->Pages=AllocMem(sizeof(struct Pages),MEMF_CLEAR|MEMF_PUBLIC);
if(hd->Pages==NULL)
{
ErrorRequest(ERROR_ALLOC);
return(FALSE);
}
hd->Memory=AllocMem(50000,MEMF_CLEAR|MEMF_PUBLIC);
if(hd->Memory==NULL)
{
ErrorRequest(ERROR_ALLOC);
return(FALSE);
}
Seek(hd->HelpFile,-4,OFFSET_END);
Read(hd->HelpFile,&b,4L);
Seek(hd->HelpFile,b,OFFSET_BEGINNING);
for(i=0;i<1000;i++)
{
Read(hd->HelpFile,&c,1L);
if(c!=0)
{
Read(hd->HelpFile,&a,2L);
Read(hd->HelpFile,&b,4L);
LENGTH(i)=a;
OFFSET(i)=b;
FLAGS(i)=c;
Read(hd->HelpFile,&b,4L);
TOFFSET(i)=b;
Read(hd->HelpFile,&b,4L);
GOFFSET(i)=b;
}
}
hd->MenuStrip=BuildMenuStrip(hd->MainWindow,7,AUTOBACKPEN);
if(hd->MenuStrip==NULL)
{
InfoRequest("Kein Speicher für Menu!");
return(FALSE);
}
hd->Page=12345;
LoadPage(hd,0);
return(TRUE);
}
VOID CloseHelp(hd)
struct HelpData *hd;
{
RemIndexGadgets(hd);
if(hd->MenuStrip) RemoveMenuStrip(hd->MenuStrip,TRUE);
if(hd->ConDev==0) CloseDevice(hd->ConReq);
if(hd->GadWindow) DeleteStdWindow(hd->GadWindow);
if(hd->TextWindow) DeleteStdWindow(hd->TextWindow);
if(hd->IndexWindow) DeleteStdWindow(hd->IndexWindow);
if(hd->MainWindow) DeleteStdWindow(hd->MainWindow);
if(hd->Screen) CloseScreen(hd->Screen);
if(hd->ConReq) DeleteExtIO(hd->ConReq);
if(hd->ConPort) DeletePort(hd->ConPort);
if(hd->Pages) FreeMem(hd->Pages,sizeof(struct Pages));
if(hd->Memory) FreeMem(hd->Memory,50000);
if(hd->OpalFont) CloseFont(hd->OpalFont);
if(hd->HelpFile) Close(hd->HelpFile);
}
VOID ConWrite(hd,text)
struct HelpData *hd;
UBYTE *text;
{
hd->ConReq->io_Data=text;
hd->ConReq->io_Length=strlen(text);
hd->ConReq->io_Command=CMD_WRITE;
SendIO(hd->ConReq);
}
VOID RefreshGadWindow(hd)
struct HelpData *hd;
{
WORD i;
static struct NewWindow GadWindowDef=
{
0,238,640,15,
0,1,
GADGETUP|ACTIVEWINDOW,
NOCAREREFRESH|BORDERLESS,
NULL,NULL,NULL,NULL,NULL,
10,10,640,256,
CUSTOMSCREEN
};
if(hd->GadWindow!=NULL)
DeleteStdWindow(hd->GadWindow);
GetTitle(hd,hd->Page);
DrawMNTextBorder(hd->MainWindow,320,10,310,12,hd->Memory);
GadWindowDef.Screen=hd->Screen;
hd->GadWindow=OpenWindow(&GadWindowDef);
if(hd->GadWindow!=NULL)
{
SetFont(hd->GadWindow->RPort,hd->OpalFont);
hd->GadUserPort=hd->GadWindow->UserPort;
hd->GadWindowSM=(1L<<hd->GadUserPort->mp_SigBit);
for(i=0;i<=3;i++) hd->NextPage[i]=0xFFFF;
if(hd->Page>0)
{
for(i=(hd->Page-1);i>=0;i--)
if(FLAGS(i)==PAGE_INDEX)
{ hd->NextPage[0]=i; break; }
}
if(hd->Page!=0) hd->NextPage[3]=0;
if(hd->Page<999)
{
for(i=(hd->Page+1);i<=999;i++)
if(FLAGS(i)==PAGE_INDEX)
{ hd->NextPage[3]=i; break; }
}
if(hd->Page>0)
{
for(i=(hd->Page-1);i>=0;i--)
{
if(FLAGS(i)!=0)
{
if(FLAGS(i)==PAGE_TEXT)
hd->NextPage[1]=i;
break;
}
}
}
if(hd->Page<999)
{
for(i=(hd->Page+1);i<=999;i++)
{
if(FLAGS(i)!=0)
{
if(FLAGS(i)==PAGE_TEXT)
hd->NextPage[2]=i;
break;
}
}
}
for(i=0;i<=3;i++)
{
if(hd->NextPage[i]!=0xFFFF)
{
GetTitle(hd,hd->NextPage[i]);
CreateMBoolGadget(hd->GadWindow,10+(i*155),1,150,12,hd->Memory,i);
}
}
}
else
{
hd->GadWindowSM=0;
hd->GadUserPort=NULL;
}
hd->WaitSM=hd->GadWindowSM+hd->MainWindowSM+hd->IndexWindowSM+hd->TextWindowSM;
}
VOID GetTitle(hd,p)
struct HelpData *hd;
LONG p;
{
LONG i,o;
i=OFFSET(p);
if(i!=0)
{
o=Seek(hd->HelpFile,i,OFFSET_BEGINNING);
Read(hd->HelpFile,hd->Memory,1024L);
Seek(hd->HelpFile,o,OFFSET_BEGINNING);
}
else hd->Memory[0]=0x00;
}
VOID LoadPage(hd,num)
struct HelpData *hd;
UWORD num;
{
if(num==hd->Page) return;
if(OFFSET(num)!=0)
{
RemIndexGadgets(hd);
hd->Page=num;
hd->Flags=FLAGS(num);
switch(hd->Flags)
{
case PAGE_INDEX:
NewProp(hd,1);
ShowIndexPage(hd,num);
break;
case PAGE_TEXT:
ShowTextPage(hd,num);
break;
}
}
else
{
DisplayBeep(hd->Screen);
DisplayBeep(hd->Screen);
}
}
VOID ShowIndexPage(hd,num)
struct HelpData *hd;
UWORD num;
{
UBYTE *m;
LONG i,j;
UWORD x,y,w;
UWORD wort;
UBYTE c;
x=15; y=11;
j=TOFFSET(num);
if(j!=0)
{
i=LENGTH(num);
Seek(hd->HelpFile,j,OFFSET_BEGINNING);
Read(hd->HelpFile,hd->Memory,i);
/* ----- Testausgabe -------------------------------------------------- */
SetAPen(hd->IndexRastPort,3);
m=hd->Memory;
for(j=0;j<i;j++)
{
c=m[j];
if(c==0x00)
{
x=15;
y+=10;
}
else
{
Move(hd->IndexRastPort,x,y);
Text(hd->IndexRastPort,&c,1L);
x=x+TextLength(hd->IndexRastPort,&c,1L);
}
}
}
/* ----- Gadgets ------------------------------------------------------ */
j=GOFFSET(num);
if(j!=0)
{
Seek(hd->HelpFile,j,OFFSET_BEGINNING);
j=0;
Read(hd->HelpFile,&wort,2L);
while((wort!=0xFFFF)&&(j<=63))
{
hd->IndexGadgetPages[j]=wort;
j++;
Read(hd->HelpFile,&wort,2L);
}
hd->IGPCount=j;
printf("Y: %ld\n",y);
hd->IGy=(195-y)/27;
hd->IGs=hd->IGPCount/hd->IGy;
hd->IGw=((552-((hd->IGs-1)*5))/hd->IGs);
printf("Gad/Spalte %ld\n",hd->IGy);
printf("Spalten %ld\n",hd->IGs);
printf("Width %ld\n",hd->IGw);
x=15;
for(i=0;i<hd->IGPCount;i++)
{
if(hd->IndexGadgetPages[i]!=2000)
{
GetTitle(hd,hd->IndexGadgetPages[i]);
hd->IndexGadgets[i]=CreateMBoolGadget(hd->IndexWindow,x,y,hd->IGw,12,hd->Memory,i);
x+=hd->IGw+5;
if(x>550) { x=15; y+=15; }
}
else
{
if(x>15)
{
x=15; y+=15;
}
y+=10;
}
}
}
/* ----- GadWindow öffnen --------------------------------------------- */
WindowToFront(hd->IndexWindow);
RefreshGadWindow(hd);
MakeMenu(hd);
}
VOID ShowTextPage(hd,num)
struct HelpData *hd;
UWORD num;
{
UBYTE *m;
UWORD wort;
REGISTER UWORD i,j,k;
REGISTER ULONG o;
hd->MenuPageCount=0;
o=GOFFSET(num);
if(o!=0)
{
Seek(hd->HelpFile,o,OFFSET_BEGINNING);
Read(hd->HelpFile,&wort,2L);
while((wort!=0xFFFF)&&(j<=24))
{
hd->MenuPages[hd->MenuPageCount]=wort;
hd->MenuPageCount++;
Read(hd->HelpFile,&wort,2L);
}
for(j=0;j<hd->MenuPageCount;j++)
{
if(hd->MenuPages[j]!=2000)
{
GetTitle(hd,hd->MenuPages[j]);
if((strlen(hd->Memory))>60) hd->Memory[59]=0x00;
strcpy(&hd->MenuNames[j],hd->Memory);
}
}
}
MakeMenu(hd);
RefreshGadWindow(hd);
hd->CurrentLine=0xFFFF;
hd->LineCount=0;
for(i=0;i<2000;i++) hd->Lines[i]=NULL;
j=LENGTH(num);
Seek(hd->HelpFile,TOFFSET(num),OFFSET_BEGINNING);
Read(hd->HelpFile,hd->Memory,j);
i=0;
while(i<j)
{
hd->Lines[hd->LineCount]=&hd->Memory[i];
i+=(strlen(&hd->Memory[i])+1);
hd->LineCount++;
}
ShowPart(hd,0);
if(hd->LineCount>ZEILEN)
hd->PropBody=hd->LineCount-ZEILEN;
else
hd->PropBody=1;
NewProp(hd,hd->PropBody);
WindowToFront(hd->TextWindow);
}
VOID ShowPart(hd,part)
struct HelpData *hd;
UWORD part;
{
UBYTE s[6];
REGISTER BYTE test;
REGISTER UWORD i,j,k;
if(part==hd->CurrentLine) return;
if(!(hd->LineCount<=ZEILEN))
{
if(part>(hd->LineCount-ZEILEN)) part=hd->LineCount-ZEILEN;
/* part = Zeile, ab der gelistet werden soll
hd->CurrentLine = Zeile, ab der gelistet wird */
if(part>hd->CurrentLine)
{ test=3; if(part-hd->CurrentLine>=ZEILEN) test=1; }
else if(part<hd->CurrentLine)
{ test=4; if(hd->CurrentLine-part>=ZEILEN) test=1; }
else if(part==hd->CurrentLine)
{ test=1; }
switch(test)
{
case 1:
hd->CurrentLine=part;
ConWrite(hd,"\f");
for(i=part;i<part+ZEILEN;i++)
{
ConWrite(hd,hd->Lines[i]);
ConWrite(hd,"\n");
}
break;
case 3:
j=part-hd->CurrentLine;
k=hd->CurrentLine+ZEILEN;
for(i=k;i<(k+j);i++)
{
ConWrite(hd,hd->Lines[i]);
ConWrite(hd,"\n");
}
hd->CurrentLine+=j;
break;
case 4:
j=hd->CurrentLine-part;
k=hd->CurrentLine;
ConWrite(hd,"\x9b");
ConWrite(hd,"H");
for(i=(k-j);i<k;i++)
{
ConWrite(hd,"\x9b");
ConWrite(hd,"L");
ConWrite(hd,hd->Lines[i]);
ConWrite(hd,"\n");
}
sprintf(&s,"%ldH",(ZEILEN+1));
ConWrite(hd,"\x9b");
ConWrite(hd,&s);
ConWrite(hd,"\x9b");
ConWrite(hd,"M");
hd->CurrentLine-=j;
break;
}
}
else
{
ConWrite(hd,"\f");
for(i=0;i<hd->LineCount;i++)
{
ConWrite(hd,hd->Lines[i]);
ConWrite(hd,"\n");
}
}
}
VOID RemIndexGadgets(hd)
struct HelpData *hd;
{
UBYTE i;
struct Gadget *gad;
for(i=0;i<64;i++)
{
gad=hd->IndexGadgets[i];
if(gad!=NULL)
{
RemoveGadget(hd->IndexWindow,gad);
hd->IndexGadgets[i]=NULL;
hd->IndexGadgetPages[i]=0;
}
}
if(hd->IndexWindow->UserData!=NULL)
{
FreeRemember(&hd->IndexWindow->UserData,TRUE);
hd->IndexWindow->UserData=NULL;
}
Move(hd->IndexRastPort,0,0);
ClearScreen(hd->IndexRastPort);
}
VOID NewProp(hd,v)
struct HelpData *hd;
UWORD v;
{
ModifyProp(hd->PropGadget,hd->MainWindow,NULL,
AUTOKNOB|PROPBORDERLESS|FREEVERT,0,0,0,65535/v);
}
struct MenuStrip
{
struct Window *Window;
struct TextAttr TextAttr;
UBYTE FrontPen;
UBYTE BackPen;
struct Menu *LastMenu;
struct MenuItem *LastItem;
struct MenuItem *LastSubItem;
struct Remember *Remember;
};
/* MenuStrip Grundstruktur erstellen */
struct MenuStrip *BuildMenuStrip(win,fp,bp)
struct Window *win;
UWORD fp,bp;
{
register struct MenuStrip *ms;
register struct RastPort *rp;
ms=AllocMem(sizeof(struct MenuStrip),MEMF_CLEAR|MEMF_PUBLIC);
if(ms!=NULL)
{
ms->Window=win;
rp=win->RPort;
ms->TextAttr.ta_Name=rp->Font->tf_Message.mn_Node.ln_Name;
ms->TextAttr.ta_YSize=rp->Font->tf_YSize;
ms->TextAttr.ta_Flags=rp->Font->tf_Flags;
ms->TextAttr.ta_Style=rp->AlgoStyle;
ms->FrontPen=fp;
ms->BackPen=bp;
}
return(ms);
}
struct Menu *AddMenu(ms,x,w,name)
struct MenuStrip *ms;
UWORD x,w;
UBYTE *name;
{
register struct Menu *me;
me=AllocRemember(&ms->Remember,sizeof(struct Menu),MEMF_CLEAR|MEMF_PUBLIC);
if(me!=NULL)
{
me->LeftEdge=x;
me->TopEdge=0;
me->Width=w;
me->Height=10;
me->Flags=MENUENABLED;
me->MenuName=name;
me->NextMenu=ms->LastMenu;
ms->LastMenu=me;
ms->LastItem=NULL;
ms->LastSubItem=NULL;
}
return(me);
}
struct MenuItem *AddItem(ms,name,w,cmd,enabled,highcomp)
struct MenuStrip *ms;
UBYTE *name;
UWORD w;
UBYTE cmd;
BOOL enabled,highcomp;
{
register struct Menu *me;
register struct MenuItem *mi;
register struct IntuiText *it;
me=ms->LastMenu;
if(me!=NULL)
{
mi=AllocRemember(&ms->Remember,sizeof(struct MenuItem)+sizeof(struct IntuiText),MEMF_CLEAR|MEMF_PUBLIC);
if(mi!=NULL)
{
it=(ULONG)mi+(ULONG)sizeof(struct MenuItem);
if(ms->LastItem!=NULL)
mi->TopEdge=ms->LastItem->TopEdge+10;
else
mi->TopEdge=0;
mi->LeftEdge=0;
mi->Width=w;
mi->Height=10;
mi->Flags=ITEMTEXT;
if(enabled) mi->Flags |= ITEMENABLED;
if(highcomp) mi->Flags |= HIGHCOMP; else mi->Flags |= HIGHNONE;
if(cmd!=0)
{
mi->Flags |= COMMSEQ;
mi->Command=cmd;
}
mi->ItemFill=it;
it->LeftEdge=AUTOLEFTEDGE;
it->TopEdge=1;
it->DrawMode=JAM1;
it->FrontPen=ms->FrontPen;
it->BackPen=ms->BackPen;
it->ITextFont=&ms->TextAttr;
it->IText=name;
mi->NextItem=ms->LastItem;
ms->LastItem=mi;
ms->LastSubItem=NULL;
me->FirstItem=mi;
}
}
return(mi);
}
VOID UseMenuStrip(ms)
struct MenuStrip *ms;
{
if(ms->LastMenu!=NULL) SetMenuStrip(ms->Window,ms->LastMenu);
}
VOID RemoveMenuStrip(ms,bool)
struct MenuStrip *ms;
BOOL bool;
{
ClearMenuStrip(ms->Window);
if(ms->Remember!=NULL) FreeRemember(&ms->Remember,TRUE);
ms->Remember=NULL;
ms->LastMenu=NULL;
ms->LastItem=NULL;
ms->LastSubItem=NULL;
if(bool==TRUE) FreeMem(ms,sizeof(struct MenuStrip));
}
UBYTE *GetOpalLine()
{
return((UBYTE *)"·········································································");
}
UBYTE *GetOpalLine450()
{
return((UBYTE *)"·················································································································");
}
VOID MacFormat(hd,tex,x)
struct HelpData *hd;
UBYTE *tex;
UWORD x;
{
REGISTER UWORD i,j,k,l;
k=strlen(tex);
l=TextLength(hd->MainRastPort,tex,k);
if(l>x)
{
i=0;
j=TextLength(hd->MainRastPort,"...",3);
l=j;
do
{
j+=TextLength(hd->MainRastPort,&tex[i],1L);
i++;
} while(j<x);
tex[i]=0x00;
strcat(tex,"...");
}
}
VOID MakeMenu(hd)
struct HelpData *hd;
{
REGISTER UWORD i,j;
RemoveMenuStrip(hd->MenuStrip,FALSE);
hd->DateiMenu=AddMenu(hd->MenuStrip,5,150,"Datei");
AddItem(hd->MenuStrip,"Einstellunden ändern",300,'E',TRUE,TRUE);
AddItem(hd->MenuStrip,"Bedienungshinweise",300,'B',TRUE,TRUE);
AddItem(hd->MenuStrip,"Information",300,'I',TRUE,TRUE);
AddItem(hd->MenuStrip,GetOpalLine(),300,0,FALSE,FALSE);
AddItem(hd->MenuStrip,"Hilfe beenden",300,'Q',TRUE,TRUE);
hd->QVMenu=AddMenu(hd->MenuStrip,160,150,"Querverweise");
if((hd->Flags==PAGE_TEXT)&&(hd->MenuPageCount>0))
{
for(i=0;i<hd->MenuPageCount;i++)
{
if(hd->MenuPages[i]!=2000)
{
MacFormat(hd,&hd->MenuNames[i],430);
AddItem(hd->MenuStrip,&hd->MenuNames[i],450,0,TRUE,TRUE);
}
else AddItem(hd->MenuStrip,GetOpalLine450(),450,0,FALSE,FALSE);
}
}
else AddItem(hd->MenuStrip,"Nicht verfügbar",300,0,TRUE,FALSE);
hd->BilderMenu=AddMenu(hd->MenuStrip,315,150,"Bilder");
AddItem(hd->MenuStrip,"Nicht verfügbar",300,0,TRUE,FALSE);
UseMenuStrip(hd->MenuStrip);
ActivateWindow(hd->MainWindow);
}
VOID Hinweise(hd)
struct HelpData *hd;
{
REGISTER UWORD i;
WindowToFront(hd->TextWindow);
RemIndexGadgets(hd);
hd->Flags=PAGE_TEXT;
hd->Page=1001;
hd->CurrentLine=0xFFFF;
hd->LineCount=Strings;
for(i=0;i<Strings;i++) hd->Lines[i]=String[i];
for( ;i<2000;i++) hd->Lines[i]=NULL;
ShowPart(hd,0);
hd->PropBody=hd->LineCount-ZEILEN;
NewProp(hd,hd->PropBody);
WindowToFront(hd->TextWindow);
}